import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

public class TestChair {
    public static void main(String[] args){
        Chair chair1 = new Chair(10,10,20);
        Chair chair2 = new Chair(20,17,16);
        Chair chair3 = new Chair(15,15,18);
        Chair chair4 = new Chair(5,20,20);

        List<Chair> chairArrayList = new ArrayList<Chair>();
        chairArrayList.add(chair1);
        chairArrayList.add(chair2);
        chairArrayList.add(chair3);
        chairArrayList.add(chair4);


        Chair chair = max(chair1,chair2,new ChairComparator());
        System.out.println("占地面积最大是："+chair.getLen());


//        升序
        Collections.sort(chairArrayList, new ChairComparator());
        for (Chair item :chairArrayList){
            System.out.println("升序长度："+item.getLen());
        }

//        逆序
        Collections.reverse(chairArrayList);
        for (Chair item :chairArrayList){
            System.out.println("逆序长度："+item.getLen());
        }
//        最大值
        Collections.max(chairArrayList ,new ChairComparator());


        for (Chair item :chairArrayList){
            System.out.println("长度："+item.getLen());
        }
        Collections.shuffle(chairArrayList);
        for (Chair item :chairArrayList){
            System.out.println("随机线性表："+item.getLen());
    }
    }
    public  static Chair max(Chair c1, Chair c2, Comparator<Chair> c){
        if (c.compare(c1,c2)<0)
            return  c1;
        else
            return  c2;
    }

}
